package org.rcloud.io.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.mapper.MapvsMapper;
import org.rcloud.io.model.Mapvs;
import org.rcloud.io.service.MapvsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/2/26.
 */
@Service(value = "MapvsService")
public class MapvsServiceImpl implements MapvsService {
    @Autowired
    MapvsMapper mapvsMapper;
    @Override
    public ResultVo deleteByPrimaryKey(Mapvs id) {

        try {
            int i = mapvsMapper.deleteByPrimaryKey(id);
            return ResultVo.setOK(i);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }
    }

    @Override
    public ResultVo insert(Mapvs record) {

        if (record.equals("") || record == null) {
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                int i = mapvsMapper.insert(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }

    }

    @Override
    public ResultVo insertSelective(Mapvs record) {

        if (record.equals("") || record == null) {
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                int i = mapvsMapper.insertSelective(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }

    }

    @Override
    public ResultVo selectByPrimaryKey(Mapvs id) {
        try {
            Mapvs mapvs = mapvsMapper.selectByPrimaryKey(id);
            return ResultVo.setOK(mapvs);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }

    }

    @Override
    public ResultVo updateByPrimaryKeySelective(Mapvs record) {

        try {
            int i = mapvsMapper.updateByPrimaryKeySelective(record);
            return ResultVo.setOK(i);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }

    }

    @Override
    public ResultVo updateByPrimaryKey(Mapvs record) {

        try {
            int i = mapvsMapper.updateByPrimaryKey(record);
            return ResultVo.setOK(i);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }

    }

    @Override
    public PageInfo<Mapvs> mapByOther(JSONObject record) {//只是JSONObject的别名，也可以写sss
        List<Mapvs> mapvsList = mapvsMapper.mapByOther(record);
        PageInfo<Mapvs> pageInfo = new PageInfo<>(mapvsList);
        return pageInfo;
    }

}
